home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 26
/
Cream of the Crop 26.iso
/
bbs
/
jukemb10.zip
/
PLAYER.NRX
< prev
next >
Wrap
Text File
|
1997-05-24
|
6KB
|
249 lines
options nocrossref
import RXFile
class player extends Frame implements MainThread
properties public
rx = RXFile()
rx2 = RXFile()
rxSet = RXFile()
rHowManyFld = Rexx
rHowManyRec = Rexx
rFieldName = Rexx[]
rFieldValue = Rexx[,]
iCount = int
iCount2 = int
iSongPlaying = int 1
iMaxLength = 0
-- rCommand = Rexx 'f:\\progs\\timidos2\\timidity.exe -Od1S -idq -L f:\\progs\\timidos2 d:\\folders\\midi\\best\\'
rCommand = Rexx 'cmd.exe /c play.cmd FILE="DRIVE:\\DIRECTORY\\'
pr2 = Process
rtime = Runtime
bPlaying = boolean 0
bStopped = boolean 0
jbplayer = jbplay
laCommand = Label("Command:")
lacurr2 = Label("[NONE] ")
tfCommand = TextField(rCommand)
bStartIt = Button("Start")
bNext = Button("Next >>")
bPrev = Button("<< Prev")
bStop = Button("Stop")
cbLoop = Checkbox("Loop list")
liTitles = List
iTitle = int
method main(s=String[]) static
s=s
player()
method player
super("Jukebox! (1 song)")
super.setResizable(1)
jbplayer = jbplay(MainThread this)
rHowManyFld = rx.linein() /* How many fields? */
rFieldName = Rexx[rHowManyFld + 1]
loop iCount = 1 to rHowManyFld
rFieldName[iCount] = rx.linein() /* Get field names */
if rFieldName[iCount].length > iMaxLength then
iMaxLength = rFieldName[iCount].length
end
rHowManyRec = rx.linein() /* How many records? */
rFieldValue = Rexx[rHowManyFld + 1, rHowManyRec + 1]
loop iCount = 1 to rHowManyRec /* Records */
loop iCount2 = 1 to rHowManyFld
rFieldValue[iCount2, iCount] = rx.linein()
end
end
/*
Now we have:
in rFieldName[1..rHowManyFld] all the field names.
in rFieldValue[1..rHowManyFld, 1..rHowManyRec] all the records that the user
has selected before calling the plugin, field by field and record by record.
*/
iTitle = 0
loop iCount = 1 to rHowManyFld
if rFieldName[iCount].upper().lastpos("TIT") \= 0 then
iTitle = iCount
end
if iTitle = 0 then exit
setupFrame
method setupFrame
cbLoop.setState(1)
liTitles = List(10, 0)
loop i = 1 to rHowManyRec
liTitles.addItem(rFieldValue[iTitle, i].strip())
end
if rxSet.stream("launcher.ini", "c", "query exists") \= "" then
do
rxSet.stream("launcher.ini", "c", "open read")
rCommand = rxSet.linein
rxSet.stream("c", "close")
end
if rCommand.strip() = "" then
rCommand = Rexx 'cmd.exe /c play.cmd FILE="DRIVE:\\DIRECTORY\\'
tfCommand.setText(rCommand)
pTwo = Panel()
pThree = Panel()
pFour = Panel()
pFive = Panel()
rtime = Runtime.getRuntime()
pTwo.setLayout(GridLayout(1, 2))
pTwo.add(laCurr2)
pTwo.add(cbLoop)
pFive.setLayout(GridLayout(2, 1))
pThree.setLayout(FlowLayout(FlowLayout.LEFT))
pThree.add(laCommand)
pThree.add(tfCommand)
pFive.add(pThree)
pFive.add(pTwo)
pFour.setLayout(GridLayout(1, 4))
pFour.add(bStartit)
pFour.add(bPrev)
pFour.add(bNext)
pFour.add(bStop)
this.add("North", pFive)
this.add("Center", liTitles)
this.add("South", pFour)
this.reshape(Toolkit.getDefaultToolkit.getScreenSize.width % 2 - 300, Toolkit.getDefaultToolkit.getScreenSize.height %2 - 140, 600, 280)
if rHowManyRec > 1 then
this.setTitle("Jukebox! ("rHowManyRec" songs)")
this.show()
method handleEvent(e=Event) returns boolean
if e.target = bStartIt then Stop(3)
if e.target = bNext then Stop(1)
if e.target = bPrev then Stop(2)
if e.target = bStop then Stop(0)
if e.target = liTitles & e.id = Event.LIST_SELECT then PlayAt(liTitles.getSelectedIndex() + 1)
if e.id=Event.WINDOW_DESTROY then
do
Stop(0)
rxSet.delete("launcher.ini")
rxSet.stream("launcher.ini", "c", "open write")
rxSet.lineout(tfCommand.getText)
rxSet.stream("c", "close")
exit
end
return super.handleEvent(e)
method Stop(i = int)
bStopped = 1
if pr2 \= null then
do
pr2.destroy()
pr2.waitFor()
pr2 = null
catch InterruptedException
end
bplaying = 0
if i = 1 then
sendNext2
else if i = 2 then
sendPrev
else if i = 3 then
sendIt
method sendNext
if bStopped = 1 then return
if iSongPlaying = rHowManyRec then
if cbLoop.getState = 0 then
return
else
iSongPlaying = 0
bPlaying = 1
iSongPlaying = iSongPlaying + 1
DiscChanger()
method sendIt
bPlaying = 1
DiscChanger()
bStopped = 0
method PlayAt(index = int)
bStopped = 1
if pr2 \= null then
do
pr2.destroy()
pr2.waitFor()
pr2 = null
catch InterruptedException
end
bPlaying = 1
iSongPlaying = index
DiscChanger()
bStopped = 0
method sendNext2
if iSongPlaying = rHowManyRec then
if cbLoop.getState = 0 then
return
else
iSongPlaying = 0
bPlaying = 1
iSongPlaying = iSongPlaying + 1
DiscChanger()
bStopped = 0
method sendPrev
if iSongPlaying = 1 then return
bPlaying = 1
iSongPlaying = iSongPlaying - 1
DiscChanger()
bStopped = 0
method DiscChanger
lacurr2.setText("Q:"rFieldValue[iTitle, iSongPlaying].strip())
jbplayer = jbplay(MainThread this)
rCommand = tfCommand.getText()
if (rCommand.countstr('"') % 2 * 2) \= rCommand.countstr('"') then
jbplayer.PlayIt(tfCommand.getText() || rFieldValue[iTitle, iSongPlaying].strip() || '"')
else
jbplayer.PlayIt(tfCommand.getText() || rFieldValue[iTitle, iSongPlaying].strip())
jbPlayer.start()
lacurr2.setText("P:"rFieldValue[iTitle, iSongPlaying].strip())
liTitles.makeVisible(iSongPlaying - 1)
liTitles.select(iSongPlaying - 1)
method setProcess(pr = Process)
pr2 = pr